'use strict';

/* App Module */

var scheduleApp = angular.module('PluginApp', [
	'ngRoute',
	'SControllers',
	]);

scheduleApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
    when('/', {
        templateUrl: 'views/index.html',
        controller: 'index_ctrl'
    }).
    otherwise({
        templateUrl: 'views/index.html',
        controller: 'index_ctrl'
    });
  }]);

scheduleApp.directive( "bnTdstate",
    function($timeout) {
        //将用户界面的事件绑定到$scope上
        function link( $scope, element, attributes ) {
            var timer = $timeout(
                function() {
                    if (element.attr('id') == "activited") {
                        element.attr("class", "success");
                    } else if (element.attr('id') == "dying") {
                        element.attr("class", "danger");
                    }
                },
                100
            );

            $scope.$on("$destroy", 
                function(event) {
                    $timeout.cancel(timer);
                }
            );
        }
        //返回指令的配置
        return({
            link: link,
            scope: false
        });

    }
);
